import 'package:flutter_taotaoshipin/http/request/ad_event_csj_request.dart';
import 'package:flutter_taotaoshipin/http/request/ad_ver_type_request.dart';
import 'package:flutter_taotaoshipin/model/ad_event_csj_entity.dart';
import 'package:flutter_taotaoshipin/model/ad_ver_type_entity.dart';
import 'package:flutter_taotaoshipin/model/base_entity.dart';
import 'package:flutter_taotaoshipin/util/device_utils.dart';
import 'package:hi_net/hi_net.dart';

class AdDao {
  /// 穿山甲广告事件记录
  static Future<BaseEntity<AdEventCsjEntity>> eventCsj({
    required String appId,
    required String adverId,
    required String eventId,
    String ecpm = '',
  }) async {
    var request = AdEventCsjRequest();
    request.add('app_id', appId);
    request.add('adver_id', adverId);
    request.add('event_id', eventId);
    request.add('ecid', Device.udid());
    request.add('model', Device.model());
    request.add('ecpm', ecpm);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<AdEventCsjEntity>.fromJson(result);
  }

  /// 广告类型配置
  static Future<BaseEntity<AdVerTypeEntity>> adVerType({
    required int adverType,
  }) async {
    var request = AdVerTypeRequest();
    request.add('adver_type', adverType);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<AdVerTypeEntity>.fromJson(result);
  }
}
